package imp

import (
	"bgs/cache/redisImp"
	"bgs/conf"
	"bgs/db"
	"bgs/grpc/client"
	brandGrpc "bgs/grpc/gen/service/brand"
	brandAdminGrpc "bgs/grpc/gen/service/brand_admin"
	brandBankCardGrpc "bgs/grpc/gen/service/brand_bank_card"
	brandDistributeRequestGrpc "bgs/grpc/gen/service/brand_distribute_request"
	brandDistributorGrpc "bgs/grpc/gen/service/brand_distributor"
	brandEndorseRequestGrpc "bgs/grpc/gen/service/brand_endorse_request"
	brandFanGrpc "bgs/grpc/gen/service/brand_fan"
	brandFollowGrpc "bgs/grpc/gen/service/brand_follow"
	brandSpokesmanGrpc "bgs/grpc/gen/service/brand_spokesman"
	brandWarehouseGrpc "bgs/grpc/gen/service/brand_warehouse"
	wxpayApplymentGrpc "bgs/grpc/gen/service/wxpay_applyment"
	activityService "bgs/service/activity"
	brandService "bgs/service/brand"
	productService "bgs/service/product"
	spokesmanService "bgs/service/spokesman"
	userService "bgs/service/user"
	warehouseService "bgs/service/warehouse"
	"bgs/util"
	wxpMinaService "bgs/wxp/mina"
	"context"
	"go.uber.org/zap"
)

// BrandAPIService :grpc server proxy of brand
type BrandAPIService struct {
	dao    *db.PgDao
	slog   *zap.SugaredLogger
	proxy  *client.GrpcClientProxy
	cacher *cache.Adapter
	brandGrpc.BrandOpServer
	brandAdminGrpc.BrandAdminOpServer
	brandDistributorGrpc.BrandDistributorOpServer
	brandDistributeRequestGrpc.BrandDistributeRequestOpServer
	brandEndorseRequestGrpc.BrandEndorseRequestOpServer
	brandFanGrpc.BrandFanOpServer
	brandFollowGrpc.BrandFollowOpServer
	brandBankCardGrpc.BrandBankCardOpServer
	brandSpokesmanGrpc.BrandSpokesmanOpServer
	brandWarehouseGrpc.BrandWarehouseOpServer
	wxpayApplymentGrpc.WxpayApplymentOpServer
	activityService  *activityService.ActivityServiceImp
	brandService     *brandService.BrandServiceImp
	productService   *productService.ProductServiceImp
	spokesmanService *spokesmanService.SpokesmanServiceImp
	userService      *userService.UserServiceImp
	warehouseService *warehouseService.WarehouseServiceImp
	wxpMinaService   *wxpMinaService.MinaServiceImp
}

// NewBrandAPIService initialization
func NewBrandAPIService(
	pgdao *db.PgDao,
	slog *zap.SugaredLogger,
	vars *conf.VarsSection,
	proxy *client.GrpcClientProxy,
	adp *cache.Adapter,
	activityService *activityService.ActivityServiceImp,
	brandService *brandService.BrandServiceImp,
	productService *productService.ProductServiceImp,
	spokesmanService *spokesmanService.SpokesmanServiceImp,
	userService *userService.UserServiceImp,
	warehouseService *warehouseService.WarehouseServiceImp,
	wxpMinaService *wxpMinaService.MinaServiceImp,
) *BrandAPIService {
	return &BrandAPIService{
		dao:              pgdao,
		slog:             slog.With("module", "BrandAPIService"),
		proxy:            proxy,
		cacher:           adp,
		activityService:  activityService,
		brandService:     brandService,
		productService:   productService,
		spokesmanService: spokesmanService,
		userService:      userService,
		warehouseService: warehouseService,
		wxpMinaService:   wxpMinaService,
	}
}

// NewContextLogger create a SugaredLogger with contextvalue
func (s *BrandAPIService) NewContextLogger(ctx context.Context) *zap.SugaredLogger {
	return util.NewContextLogger(ctx, s.slog)
}
